package lucene;

import java.util.List;

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.Query;

import cc.dullsky.lucene.model.SearchResultBean;
import cc.dullsky.lucene.operation.IndexSearch;

public class lucene2 {
	public static void main(String[] args) {
		try {

			String indexName = "dullsky";
			IndexSearch search = new IndexSearch(indexName);
			Document doc = new Document();
			QueryParser parser = new QueryParser("content", new StandardAnalyzer());
			Query query = parser.parse("dullsky");
			SearchResultBean bean = search.search(query, 0, 10);
			System.out.println(bean);
			List<Document> documents = bean.getDocs();
			for (Document document : documents) {
				System.out.println("id:\t" + document.get("id"));
				System.out.println("content:\t" + document.get("content"));
			}
			System.out.println("总条数:" + bean.getCount());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
